/*
 * BooleanCalculator.h
 *
 *  Created on: 2012. 10. 15.
 *      Author: dalxx
 */
#include "PLCConfig.h"

#ifndef BOOLEANCALCULATOR_H_
#define BOOLEANCALCULATOR_H_
#include "Relay.h"

namespace PLCLib {

class BooleanCalculator {
private:

public:

	virtual ~BooleanCalculator();

	virtual bool Calculate()=0;

	static Relay* FindRelay(char* name, Relay** relay_list, int num_list);
	static BooleanCalculator* Parse(char* expression,int start, int end, Relay** relay_list, int num_list);

};

class AndOperator : public BooleanCalculator
{
private:
	BooleanCalculator *param1, *param2;
public:
	AndOperator(BooleanCalculator* p1,BooleanCalculator* p2 );
	virtual ~AndOperator();
	virtual bool Calculate();
};


class OrOperator : public BooleanCalculator
{
private:
	BooleanCalculator *param1, *param2;
public:
	OrOperator(BooleanCalculator* p1,BooleanCalculator* p2 );
	virtual ~OrOperator();
	virtual bool Calculate();
};

class NotOperator : public BooleanCalculator
{
private:
	BooleanCalculator *param1;
public:
	NotOperator(BooleanCalculator* p1);
	virtual ~NotOperator();
	virtual bool Calculate();
};

class RelayOperator : public BooleanCalculator
{
private:
	Relay* relay;
public:
	RelayOperator(Relay *r);
	virtual ~RelayOperator();
	virtual bool Calculate();
};


} /* namespace PLCLib */
#endif /* BOOLEANCALCULATOR_H_ */
